﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

namespace NuaTarDoneng
{
    public partial class AdminUserControl : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlConnection cnn = new SqlConnection(ConfigurationManager.AppSettings["constr"]);
            SqlCommand cmd = cnn.CreateCommand();
            
            DateTime nows = DateTime.Now;
            string id = Guid.NewGuid().ToString("N");
           
            string name =TextBox1.Text.Split(',')[0];
            string pwd = TextBox1.Text.Split(',')[1];
            Random rd = new Random(DateTime.Now.Millisecond);
            int rds = rd.Next(47852936);
            cmd.CommandText = "insert into [User] (UserID,UserName,PassWord,Tails,LinkUps,timeAnchor,Role) values('" + id + "','" + name + "','" + pwd + "','" + 0 + "','" + 0 + "'," + rds + "," + 0 + ")";
            cnn.Open();
            if (cmd.ExecuteNonQuery() != 1)
            {
               
            }
            else
            {
                Response.Redirect(Request.Url.ToString());
            }
            cnn.Close();

        }
    }
}